package cmd

import (
	"fmt"
	"strings"

	"gitee.com/workits/pkgs/toolx"
	"github.com/spf13/cobra"
)

var newCmd = &cobra.Command{
	Use:   "new",
	Short: "创建新模块",
	Long:  "创建新模块",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) != 1 || strings.Contains(args[0], " ") || !toolx.IsFolderName(args[0]) {
			panic("🙅模块名称错误")
		}

		toolx.NewModule(".", args[0])

		fmt.Println("🎉模块创建完成")
	},
}

func init() {
	rootCmd.AddCommand(newCmd)
}
